//
//  MBHomeFirstPopView.m
//  Meboo
//
//  Created by kyo on 2024/4/28.
//

#import "MBHomeFirstPopView.h"
@interface MBHomeFirstPopView ()
@property (nonatomic, strong) UIButton *backBtn;
@property (nonatomic, strong) UIButton *closeBtn;
@end

@implementation MBHomeFirstPopView

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}


#pragma mark - Action
- (void)closeAction {
    self.hidden = YES;
}

- (void)nextAction {
    self.hidden = YES;
    if (self.nextBlock) {
        self.nextBlock();
    }
}

#pragma mark - UI
- (void)setupUI {
    self.hidden = YES;
    self.backgroundColor = [UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:0.5];
    
    [self addSubview:self.backBtn];
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(MBWidthScale(45));
        make.height.mas_equalTo((ScreenWidth-MBHeightScale(90))/285*250);
        make.center.equalTo(self);
    }];
    
    [self addSubview:self.closeBtn];
    [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.backBtn.mas_right).offset(MBWidthScale(-10));
        make.top.equalTo(self.backBtn.mas_top).offset(MBWidthScale(10));
        make.width.height.mas_offset(MBHeightScale(16));
    }];
}

#pragma mark - Setter && Getter

- (UIButton *)backBtn {
    if (!_backBtn) {
        _backBtn = [UIButton new];
        [_backBtn setBackgroundImage:ImageWithName(@"home_pop_first") forState:0];
        [_backBtn addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backBtn;
}

- (UIButton *)closeBtn {
    if (!_closeBtn) {
        _closeBtn = [UIButton new];
        [_closeBtn setYXEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
        [_closeBtn setBackgroundImage:ImageWithName(@"flash_chat_close") forState:0];
        [_closeBtn addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeBtn;
}
@end
